{%- assign _excerpt_truncate = include.excerpt_truncate | default: 350 -%}

{%- assign _excerpt_type = include.excerpt_type -%}

{%- include snippets/get-locale-string.html key='READMORE' -%}
{%- assign _locale_readmore = __return -%}

{%- include snippets/get-locale-string.html key='YEAR' -%}
{%- assign _locale_year = __return -%}

{%- assign _sorted_list = include.articles -%}
{%- assign _sorted_list = _sorted_list | sort: 'date' -%}
{%- if include.reverse -%}
  {%- assign _sorted_list = _sorted_list | reverse -%}
{%- endif -%}

{%- if include.type == 'item' -%}
<div class="article-list items items-divided">
{%- elsif include.type == 'brief' -%}
<div class="article-list items">
{%- elsif include.type == 'grid' -%}
  {%- if include.size == 'sm' -%}
<div class="article-list grid gird-sm grid-p-3">
  {%- else -%}
<div class="article-list grid grid-p-3">
  {%- endif -%}
{%- endif -%}

{%- assign _last_year = '' -%}

  {%- for _article in _sorted_list -%}

    {%- include snippets/prepend-baseurl.html path=_article.url -%}
    {%- assign _article_url = __return -%}

    {%- if _article.cover -%}
      {%- include snippets/get-nav-url.html path=_article.cover -%}
      {%- assign _article_cover = __return -%}
    {%- endif -%}

    {%- if include.type == 'item' -%}
      {%- if include.article_type == 'BlogPosting' -%}
        <article class="item" itemscope itemtype="http://schema.org/BlogPosting">
      {%- else -%}
        <article class="item">
      {%- endif -%}
        {%- if _article.cover and include.show_cover-%}
          {%- include snippets/get-nav-url.html path=_article.cover -%}
          {%- assign _article_cover = __return -%}
          <div class="item_image">
          {%- if include.cover_size == 'lg' -%}
            <img class="image image-lg" src="{{ _article_cover }}" />
          {%- elsif include.cover_size == 'sm' -%}
            <img class="image image-sm" src="{{ _article_cover }}" />
          {%- else -%}
            <img class="image" src="{{ _article_cover }}" />
          {%- endif -%}
          </div>
        {%- endif -%}
        <div class="item_content">
          <header><a href="{{ _article_url }}"><h2 itemprop="headline" class="item_header">{{ _article.title }}</h2></a></header>
          <div class="item_description">
            {%- if _article.excerpt and include.show_excerpt -%}
              <div class="article_content" itemprop="description articleBody">
                {%- if _excerpt_type == 'html' -%}
                  {{ _article.excerpt }}
                {%- else -%}
                  {{ _article.excerpt | strip_html | strip | truncate: _excerpt_truncate }}
                {%- endif -%}
              </div>
            {%- endif -%}
            {%- if include.show_readmore -%}
              <p><a href="{{ _article_url }}">{{ _locale_readmore }} »</a></p>
            {%- endif -%}
          </div>
          {%- if include.show_info -%}
            {%- include snippets/assign.html target=site.data.variables.default.page.pageview source0=_article.pageview -%}
            {%- assign _show_pageview = __return -%}
            {%- include article-info.html article=_article show_pageview=_show_pageview -%}
          {%- endif -%}
        </div>
      </article>

    {%- elsif include.type == 'brief' -%}
      {%- assign _article_year = _article.date | date: '%Y' -%}
      {%- assign _current_year = _article_year | strip | url_encode -%}
      {%- if _current_year != _last_year -%}
        {%- unless forloop.first -%}</ul></section>{%- endunless -%}
        <section><h2 class="article-list_group-header">{{ _current_year }} {{ _locale_year }}</h2><ul class="items">
        {%- assign _last_year = _current_year -%}
      {%- endif -%}
      {%- include snippets/get-locale-string.html key='ARTICLE_LIST_DATE_FORMAT' -%}
      {%- assign _article_date_format = __return -%}
      <li class="item" itemscope itemtype="http://schema.org/BlogPosting" data-archive="{{ _current_year }}">
        <table class="item_content item_table_brief">
        <tbody>
          <tr>
          {%- if include.show_info -%}
            <td class="item_table_brief_td" width="88px;5.5rem;"><span class="item_meta_brief">{{ _article.date | date: _article_date_format }}</span></td>
          {%- endif -%}
          <td class="item_table_brief_td" witdh="auto"><a itemprop="headline" class="item_header_brief" href="{{ _article_url }}">{{ _article.title }}</a></td>
          </tr>
        </tbody>
        </table>
      </li>
      {%- if forloop.last -%}</ul></section>{%- endif -%}

    {%- elsif include.type == 'grid' -%}
      {%- if include.size == 'sm' -%}
        <div class="cell cell-12 cell-md-4 cell-lg-3">
          <div class="card card-flat">
            {%- if _article.cover -%}
              <div class="card_image">
                <img class="image" src="{{ _article_cover }}" />
                <div class="overlay overlay-bottom">
                  <header>
                    <a href="{{ _article_url }}"><h2 class="card_header">{{ _article.title }}</h2></a>
                  </header>
                </div>
              </div>
            {%- endif -%}
            </div>
        </div>
      {%- else -%}
        <div class="cell cell-12 cell-md-6 cell-lg-4">
          <div class="card card-flat">
            {%- if _article.cover -%}
              <div class="card_image"><img src="{{ _article_cover }}" /></div>
            {%- endif -%}
              <div class="card_content">
                <header>
                  <a href="{{ _article_url }}"><h2 class="card_header">{{ _article.title }}</h2></a>
                </header>
              </div>
          </div>
        </div>
      {%- endif -%}
    {%- endif -%}

  {%- endfor -%}
</div>
<p>&nbsp;</p>